#include "chuangjian.h"
//尾插
void Tail(DNode** p,ElemType insertData){
    //无效参数
    if (NULL == p){
    printf("数据有误，程序终止\n");
    return;
    }
    DNode* pNew = createDNode(insertData);
    //无效参数
    if (NULL == pNew){
    printf("数据有误，程序终止\n");
    return;
    }
    DNode* ptemp = *p;
    if(ptemp){//不是空链表
        while(ptemp->prior)
            ptemp = ptemp->prior;
        ptemp->prior = pNew;
    }else{//是空链表
        *p = pNew;
    }
}
//从头开始
void travelnext(DNode* p){
    if(NULL == p){
    printf("遍历失败\n");
    return;
    }
    while (p)
    {
        printf("%d", p ->data);
        p = p ->prior;
        sleep(1);
    }printf("\n");
}
//创建节点
DNode* createDNode(ElemType data){
    //创建内存空间
    DNode* pnew = (DNode*)malloc(SIZE);
    if(NULL == pnew){
        printf("申请失败，程序结束\n");
        return NULL;
    }
    //全体赋值为0
    memset(pnew, 0, SIZE);
    pnew ->data = 0;
    return pnew;
}